package com.zheng.upms.rpc.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zheng.common.annotation.BaseService;
import com.zheng.common.base.BaseServiceImpl;
import com.zheng.upms.dao.mapper.UpmsSystemMapper;
import com.zheng.upms.dao.model.UpmsSystem;
import com.zheng.upms.rpc.api.UpmsSystemService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 系统 服务实现类
 * </p>
 *
 * @author likun
 * @since 2017-12-29
 */
@Service
@Transactional
@BaseService
public class UpmsSystemServiceImpl extends BaseServiceImpl<UpmsSystemMapper, UpmsSystem> implements UpmsSystemService {

    @Override
    @Cacheable(value = "zheng-upms-rpc-service-ehcache", key = "'selectSystemByName' + #name")
    public UpmsSystem selectByName(String name) {
        List<UpmsSystem> upmsSystems = super.baseMapper.selectList(new EntityWrapper<UpmsSystem>().eq("name", name));
        if (null != upmsSystems && upmsSystems.size() > 0) {
            return upmsSystems.get(0);
        }
        return null;
    }
}
